package com.freeman.boot.auth;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.AuthenticationException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class WeChatController {

    private static final Logger LOGGER = LoggerFactory.getLogger(WeChatController.class);

    @Autowired
    private WeChatService weChatService;

    @RequestMapping(value = "wechat/jsconfig", method = RequestMethod.GET)
    public ResponseEntity<?> getWeChatJsConfig(String url) throws AuthenticationException {
        LOGGER.info("请求签名的地址为:{}", url);
        // Return the sign
        return ResponseEntity.ok(weChatService.getWeChatJsConfig(url));
    }
}